package com.woniu.Service;

import com.woniu.entity.Dept;
import com.woniu.entity.DeptExample;
import com.woniu.mapper.DeptMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class DeptServiceImpl implements DeptService{
    @Resource
    DeptMapper deptMapper;

    @Override
    public List<Dept> findAll() {
        return deptMapper.selectByExample(null);
    }

    @Override
    public boolean addDept(Dept dept) {
        return deptMapper.insertSelective(dept) > 0 ? true : false;
    }

    @Override
    public boolean delDept(Integer dno) {
        return deptMapper.deleteByPrimaryKey(dno) > 0 ? true : false;
    }

    @Override
    public boolean upDept(Dept dept) {
        DeptExample example = new DeptExample();
        example.createCriteria().andDnoEqualTo(dept.getDno());
        return deptMapper.updateByExampleSelective(dept,example)  > 0 ? true : false;
    }
}
